﻿using NCP.Recruiting.ApplicationServices.Interfaces;
using NCP.Recruiting.ApplicationServices.ViewModels;
using NCP.Recruiting.Web.Framework.ActionExtend;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace NCP.Recruiting.WebApp.Controllers
{
    public class ResumeDownloadController : Controller
    {
        private readonly IResumeAppService _resumeAppService;
        public ResumeDownloadController(IResumeAppService resumeAppService)
        {
            this._resumeAppService = resumeAppService;
        }
       
        public ActionResult ResumePriview(Guid id)
        {
            var response = _resumeAppService.GetViewModelById(id);
            response.IsResumePriview = true;
            return View(response);
        }

        [HttpPost]
        public ActionResult PriviewDownload(ResumeViewModel model)
        {
            string url = Url.Action("ResumePriview", "ResumeDownload", new { id = model.ResumeId }, "http");
            return new WordActionResult(url, model.FullName + ".doc");
        }
    }
}
